package top.wilbert.collegelink.search.service.impl;/**
 * @author augus
 * @create 2023-03-20-20:02
 */

import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.wilbert.collegelink.search.config.CollegelinkElasticSearchConfig;
import top.wilbert.collegelink.search.constant.EsConstant;
import top.wilbert.collegelink.search.service.ElasticDeleteService;

import java.io.IOException;

/**
 * @ClassName:ElasticDeleteServiceImpl
 * @Description:
 * @author Augus
 * @date 2023/3/20 20:02
 * @Version 1.0
 **/
@Service("elasticDeleteService")
public class ElasticDeleteServiceImpl implements ElasticDeleteService {

    @Autowired
    RestHighLevelClient restHighLevelClient;

    @Override
    public void talkStatusClose(Long talkId) throws IOException {
        DeleteRequest deleteRequest = new DeleteRequest(EsConstant.TALK_INDEX);
        deleteRequest.id(talkId.toString());
        restHighLevelClient.delete(deleteRequest, CollegelinkElasticSearchConfig.COMMON_OPTIONS.DEFAULT);
    }
}
